<?php

class Ext_Cropzoom
{
    private $_adapter;
    
    protected static $_instance = null;

    public static function getInstance()
    {
        if (null === self::$_instance) {
            self::$_instance = new self();
        }

        return self::$_instance;
    }
    
    public function __construct()
    {
        if(!isset($this->_adapter))
        {
            $classname = "Ext_Cropzoom_Adapter_Gd";
            if(!class_exists( $classname ))
            {
                require_once 'Ext/Cropzoom/Exception.php';
                throw new Ext_Cropzoom_Exception("Avatar cropzoom adapter '".$classname."' is not exists.");
            }
            
            $this->_adapter = new $classname();
        }
    }
    
    public function getAdapter()
    {
        $_adapter = $this->_adapter;
        return $_adapter;
    }
    
    public function setSourceImage($imageFile)
    {
        $this->_adapter->setSourceImage($imageFile);
    }
    
    public function setDestinationImage($imageFile)
    {
        $this->_adapter->setDestinationImage($imageFile);
    }
    
    public function graphics($setting) 
    {
        $this->_adapter->graphics($setting);    
    }
}
